from typing import Optional
from datetime import datetime
from pydantic import Field
from server.schemas.BaseSchema import BaseSchema

class LogBase(BaseSchema):
    """日志基础Schema"""
    action: str = Field(..., max_length=255)
    method: str = Field(..., max_length=10)
    path: str = Field(..., max_length=255)
    status_code: int

class LogCreate(LogBase):
    """日志创建Schema"""
    user_id: Optional[str] = None
    params: Optional[str] = None
    ip_address: Optional[str] = Field(None, max_length=50)
    user_agent: Optional[str] = Field(None, max_length=255)
    response: Optional[str] = None

class LogInDB(LogBase):
    """数据库日志Schema"""
    id: str
    user_id: Optional[str]
    params: Optional[str]
    ip_address: Optional[str]
    user_agent: Optional[str]
    response: Optional[str]
    created_at: datetime